package it.duecaffe.claysoftware.interventi.client;

import it.duecaffe.claysoftware.interventi.client.handler.ClayEventHandlerImpl;
import it.duecaffe.claysoftware.interventi.client.handler.InserisciInterventoEvent;
import it.duecaffe.claysoftware.interventi.client.handler.LoginEvent;
import it.duecaffe.claysoftware.interventi.client.handler.MenuEvent;
import it.duecaffe.claysoftware.interventi.client.handler.Utils;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.dom.client.Style.Display;
import com.google.gwt.user.client.DOM;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class ClaysoftwareGWT implements EntryPoint {
	
	/**
	 * This is the entry point method.
	 */
	public void onModuleLoad() {
		registerHandler();
		ClayEventHandlerImpl.getInstance().start();
		hideLoadingPanel("loading");
	}

	private void registerHandler() {
		Utils.EVENT_BUS.addHandler(LoginEvent.TYPE, ClayEventHandlerImpl.getInstance());
		Utils.EVENT_BUS.addHandler(MenuEvent.TYPE, ClayEventHandlerImpl.getInstance());
		Utils.EVENT_BUS.addHandler(InserisciInterventoEvent.TYPE, ClayEventHandlerImpl.getInstance());
	}
	
	public static void hideLoadingPanel(String id) {
		DOM.getElementById(id).getStyle().setDisplay(Display.NONE);
	  }
	
}
